import React, { useState } from 'react';
import authService from '../services/authService';
import './css/Register.css'; // 引入样式文件

const Register = ({ onRegisterSuccess }) => {
    const [username, setUsername] = useState('');
    const [password, setPassword] = useState('');
    const [email, setEmail] = useState('');
    const [error, setError] = useState('');

    const handleSubmit_register = async (e) => {
        e.preventDefault();
        try {
            let data = await authService.register({ username, email, password });
            if(data.code ===1 ){
                //路由到主页 已登录
                localStorage.setItem('token',data.msg)
                onRegisterSuccess(data.data);
            }
        } catch (err) {
            setError('Registration failed');
        }
    };

    return (
        <div className="container"> {/* 添加容器类名 */}

        </div>
    );
};

export default Register;
